/*
* Copyright (c) 2025 Huawei Technologies Co., Ltd.
* openUBMC is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*         http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/

#include <gtest/gtest.h>
#include <test_utilities/test_base.h>
#include "interface/network_adapter/cooling.h"
#include <ncsi_over_mctp/ncsi_over_mctp_mellanox.h>
#include <mctp/mctp.h>
#include <mc/engine.h>
#include <mc/common.h>
#include <ncsi/ncsi_mellanox.h>
#include <ncsi/ncsi_protocol.h>
#include "mock_ipmi_core.h"
#include <ctime>
#include <thread>
#include <chrono>
#include <functional>
#include <vector>
#include <string>

using namespace dev;

// 声明外部 MCTP 请求处理器设置函数
namespace dev {
void set_mctp_request_handler(std::function<bool(const mc::dict&, const std::vector<uint8_t>&,
                                                 std::string&)> handler);
}

namespace drivers {
namespace pcie_nic_card {
namespace mellanox {
namespace interface {
namespace test {

namespace {
// 字节序转换辅助函数
constexpr uint16_t host_to_be16(uint16_t value) {
    return static_cast<uint16_t>(((value & 0x00FFU) << 8U) | ((value & 0xFF00U) >> 8U));
}
} // namespace

class cooling_test_service : public mc::engine::service {
public:
    cooling_test_service(const std::string& name) : mc::engine::service(name) {}
};

// ========================= NetworkAdapter_Cooling测试 =========================
class NetworkAdapterCoolingTest : public mc::test::TestWithEngine {
protected:
    static void SetUpTestSuite() {
        TestWithEngine::SetUpTestSuite();
        m_test_service = std::make_unique<cooling_test_service>("bmc.openubmc.test_cooling");
        m_test_service->init();
        m_test_service->start();
        
        // 注册 mock IpmiCore 接口，避免真实的 D-Bus 调用
        m_ipmi_core_obj = test_ipmi_core_object::create();
        m_ipmi_core_obj->set_object_path("/bmc/kepler/IpmiCore");
        m_ipmi_core_obj->set_object_name("bmc.kepler.IpmiCore");
        m_test_service->register_object(m_ipmi_core_obj);
    }
    static void TearDownTestSuite() {
        try {
            if (m_ipmi_core_obj && m_test_service) {
                m_test_service->unregister_object(m_ipmi_core_obj);
                m_ipmi_core_obj.reset();
            }
            if (m_test_service) {
                m_test_service->stop();
                m_test_service.reset();
            }
            TestWithEngine::TearDownTestSuite();
        } catch (...) {
            if (m_ipmi_core_obj) {
                m_ipmi_core_obj.reset();
            }
            if (m_test_service) {
                m_test_service.reset();
            }
        }
    }
    void SetUp() override {
        static int test_counter = 0;
        test_counter++;
        std::string object_name =
            "test_cooling_" + std::to_string(test_counter) + "_" + std::to_string(std::time(nullptr));
        std::string position = std::to_string(test_counter + 400);

        m_cooling = mc::make_shared<dev::NetworkAdapter_Cooling>();

        // 创建真实的 ncsi_over_mctp_mellanox，通过 MCTP 请求处理器来模拟响应
        m_mctp = mc::make_shared<dev::mctp>(nullptr, 0, dev::MCTP_MESSAGE_TYPE_NCSI, "");
        m_ncsi = std::make_shared<dev::ncsi_over_mctp_mellanox>(*m_mctp);
    }
    void TearDown() override {
        try {
            if (m_cooling) {
                m_cooling->stop_ncsi_update_task();
                std::this_thread::sleep_for(std::chrono::milliseconds(10));
                m_cooling.reset();
            }
            // 清理 MCTP 请求处理器，避免影响其他测试
            dev::set_mctp_request_handler(nullptr);
            m_ncsi.reset();
            m_mctp.reset();
        } catch (...) {
            if (m_cooling) {
                m_cooling.reset();
            }
        }
    }

    static std::unique_ptr<cooling_test_service> m_test_service;
    static mc::shared_ptr<test_ipmi_core_object> m_ipmi_core_obj;
    mc::shared_ptr<dev::NetworkAdapter_Cooling>  m_cooling;
    mc::shared_ptr<dev::mctp>                    m_mctp;
    std::shared_ptr<dev::ncsi_over_mctp_mellanox> m_ncsi;
};
std::unique_ptr<cooling_test_service> NetworkAdapterCoolingTest::m_test_service;
mc::shared_ptr<test_ipmi_core_object> NetworkAdapterCoolingTest::m_ipmi_core_obj;

// ========================= 基本功能测试 =========================

TEST_F(NetworkAdapterCoolingTest, Constructor) {
    dev::NetworkAdapter_Cooling cooling;
    EXPECT_TRUE(true);
}

TEST_F(NetworkAdapterCoolingTest, Destructor_CleansUpResources) {
    auto cooling = mc::make_shared<dev::NetworkAdapter_Cooling>();

    // 启动任务后析构
    mc::milliseconds interval(1000);
    uint8_t          package_id = 0;
    cooling->start_ncsi_update_task_mellanox(m_ncsi, interval, package_id);
    std::this_thread::sleep_for(std::chrono::milliseconds(50));

    cooling->stop_ncsi_update_task();
    std::this_thread::sleep_for(std::chrono::milliseconds(10));
    cooling.reset();

    EXPECT_TRUE(cooling == nullptr);
}

// ========================= update_chip_temp_by_ncsi 测试 =========================

TEST_F(NetworkAdapterCoolingTest, UpdateChipTempByNcsi_Success) {
    // 设置 MCTP 请求处理器，返回模拟的温度信息
    dev::set_mctp_request_handler([](const mc::dict& ctx, const std::vector<uint8_t>& data,
                                     std::string& rsp) {
        // 检查是否是 OEM 命令
        if (!ctx.contains("PacketType") ||
            ctx.at("PacketType").as<int64_t>() != OEM_COMMAND) {
            return false;
        }
        
        // 检查是否是获取温度命令
        if (data.size() < 8 || data[5] != OEM_MLNX_GET_TEMP_CMD || data[6] != OEM_MLNX_GET_TEMP_PARA) {
            return false;
        }
        
        // 构造响应：cur_temp=50, max_operating_temp=100
        oem_mlnx_temp_rsp_t temp_rsp = {};
        temp_rsp.public_rsp_header.response_code = host_to_be16(COMMAND_COMPLETED);
        temp_rsp.public_rsp_header.reason_code = host_to_be16(NOERROR_OR_NOREASON);
        temp_rsp.public_rsp_header.manufacturer_id = MELLANOX_MANUFACTURE_ID_REP;
        temp_rsp.public_rsp_header.command_id = OEM_MLNX_GET_TEMP_CMD;
        temp_rsp.public_rsp_header.parameter = OEM_MLNX_GET_TEMP_PARA;
        temp_rsp.max_operating_temp = 100;
        temp_rsp.cur_temp = 50;
        
        rsp = std::string(reinterpret_cast<const char*>(&temp_rsp), sizeof(temp_rsp.public_rsp_header) + 4);
        return true;
    });

    // 需要先设置 ncsi_over_mctp_mellanox
    mc::milliseconds interval(1000);
    uint8_t          package_id = 0;
    m_cooling->start_ncsi_update_task_mellanox(m_ncsi, interval, package_id);
    std::this_thread::sleep_for(std::chrono::milliseconds(50));

    bool result = m_cooling->update_chip_temp_by_ncsi();
    EXPECT_TRUE(result);
    EXPECT_EQ(m_cooling->TemperatureCelsius.get_value(), 50);
    EXPECT_EQ(m_cooling->TemperatureStatus.get_value(), 0); // cur_temp < max_operating_temp
}

TEST_F(NetworkAdapterCoolingTest, UpdateChipTempByNcsi_GetTempInfoFailed) {
    // 设置 MCTP 请求处理器返回失败
    dev::set_mctp_request_handler([](const mc::dict&, const std::vector<uint8_t>&, std::string&) {
        return false;
    });

    mc::milliseconds interval(1000);
    uint8_t          package_id = 0;
    m_cooling->start_ncsi_update_task_mellanox(m_ncsi, interval, package_id);
    std::this_thread::sleep_for(std::chrono::milliseconds(50));

    bool result = m_cooling->update_chip_temp_by_ncsi();
    EXPECT_FALSE(result);
}

TEST_F(NetworkAdapterCoolingTest, UpdateChipTempByNcsi_TemperatureExceedsMax) {
    // 设置 MCTP 请求处理器，返回超过最大温度的温度信息
    dev::set_mctp_request_handler([](const mc::dict& ctx, const std::vector<uint8_t>& data,
                                     std::string& rsp) {
        if (!ctx.contains("PacketType") ||
            ctx.at("PacketType").as<int64_t>() != OEM_COMMAND) {
            return false;
        }
        if (data.size() < 8 || data[5] != OEM_MLNX_GET_TEMP_CMD || data[6] != OEM_MLNX_GET_TEMP_PARA) {
            return false;
        }
        
        oem_mlnx_temp_rsp_t temp_rsp = {};
        temp_rsp.public_rsp_header.response_code = host_to_be16(COMMAND_COMPLETED);
        temp_rsp.public_rsp_header.reason_code = host_to_be16(NOERROR_OR_NOREASON);
        temp_rsp.public_rsp_header.manufacturer_id = MELLANOX_MANUFACTURE_ID_REP;
        temp_rsp.public_rsp_header.command_id = OEM_MLNX_GET_TEMP_CMD;
        temp_rsp.public_rsp_header.parameter = OEM_MLNX_GET_TEMP_PARA;
        temp_rsp.max_operating_temp = 80;
        temp_rsp.cur_temp = 100;
        
        rsp = std::string(reinterpret_cast<const char*>(&temp_rsp), sizeof(temp_rsp.public_rsp_header) + 4);
        return true;
    });

    mc::milliseconds interval(1000);
    uint8_t          package_id = 0;
    m_cooling->start_ncsi_update_task_mellanox(m_ncsi, interval, package_id);
    std::this_thread::sleep_for(std::chrono::milliseconds(50));

    bool result = m_cooling->update_chip_temp_by_ncsi();
    EXPECT_TRUE(result);
    EXPECT_EQ(m_cooling->TemperatureCelsius.get_value(), 100);

    EXPECT_EQ(m_cooling->TemperatureStatus.get_value(), 0);
}

TEST_F(NetworkAdapterCoolingTest, UpdateChipTempByNcsi_TemperatureAtBoundary) {
    // 设置 MCTP 请求处理器，返回边界温度信息
    dev::set_mctp_request_handler([](const mc::dict& ctx, const std::vector<uint8_t>& data,
                                     std::string& rsp) {
        if (!ctx.contains("PacketType") ||
            ctx.at("PacketType").as<int64_t>() != OEM_COMMAND) {
            return false;
        }
        if (data.size() < 8 || data[5] != OEM_MLNX_GET_TEMP_CMD || data[6] != OEM_MLNX_GET_TEMP_PARA) {
            return false;
        }
        
        oem_mlnx_temp_rsp_t temp_rsp = {};
        temp_rsp.public_rsp_header.response_code = host_to_be16(COMMAND_COMPLETED);
        temp_rsp.public_rsp_header.reason_code = host_to_be16(NOERROR_OR_NOREASON);
        temp_rsp.public_rsp_header.manufacturer_id = MELLANOX_MANUFACTURE_ID_REP;
        temp_rsp.public_rsp_header.command_id = OEM_MLNX_GET_TEMP_CMD;
        temp_rsp.public_rsp_header.parameter = OEM_MLNX_GET_TEMP_PARA;
        temp_rsp.max_operating_temp = 80;
        temp_rsp.cur_temp = 80;
        
        rsp = std::string(reinterpret_cast<const char*>(&temp_rsp), sizeof(temp_rsp.public_rsp_header) + 4);
        return true;
    });

    mc::milliseconds interval(1000);
    uint8_t          package_id = 0;
    m_cooling->start_ncsi_update_task_mellanox(m_ncsi, interval, package_id);
    std::this_thread::sleep_for(std::chrono::milliseconds(50));

    bool result = m_cooling->update_chip_temp_by_ncsi();
    EXPECT_TRUE(result);
    EXPECT_EQ(m_cooling->TemperatureCelsius.get_value(), 80);
    EXPECT_EQ(m_cooling->TemperatureStatus.get_value(), 0);
}

// ========================= update_max_sfp_temperature 测试 =========================

TEST_F(NetworkAdapterCoolingTest, UpdateMaxSfpTemperature_Success) {
    uint16_t max_temperature = 85;
    uint8_t  status          = 0;

    bool result = m_cooling->update_max_sfp_temperature(max_temperature, status);
    EXPECT_TRUE(result);
    EXPECT_EQ(m_cooling->MaxSFPTemperatureCelsius.get_value(), 85);
    EXPECT_EQ(m_cooling->MaxSFPTemperatureStatus.get_value(), 0);
}

TEST_F(NetworkAdapterCoolingTest, UpdateMaxSfpTemperature_WithStatus) {
    uint16_t max_temperature = 90;
    uint8_t  status          = 1;

    bool result = m_cooling->update_max_sfp_temperature(max_temperature, status);
    EXPECT_TRUE(result);
    EXPECT_EQ(m_cooling->MaxSFPTemperatureCelsius.get_value(), 90);
    EXPECT_EQ(m_cooling->MaxSFPTemperatureStatus.get_value(), 1);
}

TEST_F(NetworkAdapterCoolingTest, UpdateMaxSfpTemperature_BoundaryValues) {
    // 测试边界值
    uint16_t max_temperature = 0;
    uint8_t  status          = 0;
    bool     result          = m_cooling->update_max_sfp_temperature(max_temperature, status);
    EXPECT_TRUE(result);
    EXPECT_EQ(m_cooling->MaxSFPTemperatureCelsius.get_value(), 0);
    EXPECT_EQ(m_cooling->MaxSFPTemperatureStatus.get_value(), 0);

    max_temperature = 255;
    status          = 255;
    result          = m_cooling->update_max_sfp_temperature(max_temperature, status);
    EXPECT_TRUE(result);
    EXPECT_EQ(m_cooling->MaxSFPTemperatureCelsius.get_value(), 255);
    EXPECT_EQ(m_cooling->MaxSFPTemperatureStatus.get_value(), 255);
}

// ========================= start_ncsi_update_task_mellanox 测试 =========================

TEST_F(NetworkAdapterCoolingTest, StartNcsiUpdateTask_Success) {
    mc::milliseconds interval(1000);
    uint8_t          package_id = 0;

    m_cooling->start_ncsi_update_task_mellanox(m_ncsi, interval, package_id);
    std::this_thread::sleep_for(std::chrono::milliseconds(50));

    // 验证任务已启动，可以通过停止来验证
    m_cooling->stop_ncsi_update_task();
    EXPECT_TRUE(true);
}

TEST_F(NetworkAdapterCoolingTest, StartNcsiUpdateTask_WithNullNcsi) {
    mc::milliseconds              interval(1000);
    uint8_t                       package_id = 0;
    dev::ncsi_over_mctp_mellanox_ptr null_ncsi = nullptr;

    // 应该能正常处理空指针
    m_cooling->start_ncsi_update_task_mellanox(null_ncsi, interval, package_id);
    std::this_thread::sleep_for(std::chrono::milliseconds(50));

    m_cooling->stop_ncsi_update_task();
    EXPECT_TRUE(true);
}

TEST_F(NetworkAdapterCoolingTest, StartNcsiUpdateTask_DifferentIntervals) {
    std::vector<mc::milliseconds> intervals = {mc::milliseconds(100), mc::milliseconds(500),
                                               mc::milliseconds(1000)};
    uint8_t                       package_id = 0;

    for (auto& interval : intervals) {
        m_cooling->start_ncsi_update_task_mellanox(m_ncsi, interval, package_id);
        std::this_thread::sleep_for(std::chrono::milliseconds(50));
        m_cooling->stop_ncsi_update_task();
        std::this_thread::sleep_for(std::chrono::milliseconds(10));
    }
    EXPECT_TRUE(true);
}

TEST_F(NetworkAdapterCoolingTest, StartNcsiUpdateTask_DifferentPackageIds) {
    mc::milliseconds interval(1000);
    std::vector<uint8_t> package_ids = {0, 1, 2, 255};

    for (auto package_id : package_ids) {
        m_cooling->start_ncsi_update_task_mellanox(m_ncsi, interval, package_id);
        std::this_thread::sleep_for(std::chrono::milliseconds(50));
        m_cooling->stop_ncsi_update_task();
        std::this_thread::sleep_for(std::chrono::milliseconds(10));
    }
    EXPECT_TRUE(true);
}

TEST_F(NetworkAdapterCoolingTest, StartNcsiUpdateTask_MultipleStarts) {
    mc::milliseconds interval(1000);
    uint8_t          package_id = 0;

    // 多次启动应该能正常处理
    m_cooling->start_ncsi_update_task_mellanox(m_ncsi, interval, package_id);
    std::this_thread::sleep_for(std::chrono::milliseconds(50));
    m_cooling->start_ncsi_update_task_mellanox(m_ncsi, interval, package_id);
    std::this_thread::sleep_for(std::chrono::milliseconds(50));

    m_cooling->stop_ncsi_update_task();
    EXPECT_TRUE(true);
}

// ========================= stop_ncsi_update_task 测试 =========================

TEST_F(NetworkAdapterCoolingTest, StopNcsiUpdateTask_WithoutStart) {
    // 未启动时停止应该能正常处理
    m_cooling->stop_ncsi_update_task();
    EXPECT_TRUE(true);
}

TEST_F(NetworkAdapterCoolingTest, StopNcsiUpdateTask_AfterStart) {
    mc::milliseconds interval(1000);
    uint8_t          package_id = 0;

    m_cooling->start_ncsi_update_task_mellanox(m_ncsi, interval, package_id);
    std::this_thread::sleep_for(std::chrono::milliseconds(50));

    m_cooling->stop_ncsi_update_task();
    std::this_thread::sleep_for(std::chrono::milliseconds(10));
    EXPECT_TRUE(true);
}

TEST_F(NetworkAdapterCoolingTest, StopNcsiUpdateTask_MultipleStops) {
    mc::milliseconds interval(1000);
    uint8_t          package_id = 0;

    m_cooling->start_ncsi_update_task_mellanox(m_ncsi, interval, package_id);
    std::this_thread::sleep_for(std::chrono::milliseconds(50));

    // 多次停止应该能正常处理
    m_cooling->stop_ncsi_update_task();
    m_cooling->stop_ncsi_update_task();
    m_cooling->stop_ncsi_update_task();
    EXPECT_TRUE(true);
}

// ========================= 定时器回调测试 =========================

TEST_F(NetworkAdapterCoolingTest, TimerCallback_UpdatesTemperature) {
    // 设置 MCTP 请求处理器
    dev::set_mctp_request_handler([](const mc::dict& ctx, const std::vector<uint8_t>& data,
                                     std::string& rsp) {
        if (!ctx.contains("PacketType") ||
            ctx.at("PacketType").as<int64_t>() != OEM_COMMAND) {
            return false;
        }
        if (data.size() < 8 || data[5] != OEM_MLNX_GET_TEMP_CMD || data[6] != OEM_MLNX_GET_TEMP_PARA) {
            return false;
        }
        
        oem_mlnx_temp_rsp_t temp_rsp = {};
        temp_rsp.public_rsp_header.response_code = host_to_be16(COMMAND_COMPLETED);
        temp_rsp.public_rsp_header.reason_code = host_to_be16(NOERROR_OR_NOREASON);
        temp_rsp.public_rsp_header.manufacturer_id = MELLANOX_MANUFACTURE_ID_REP;
        temp_rsp.public_rsp_header.command_id = OEM_MLNX_GET_TEMP_CMD;
        temp_rsp.public_rsp_header.parameter = OEM_MLNX_GET_TEMP_PARA;
        temp_rsp.max_operating_temp = 100;
        temp_rsp.cur_temp = 60;
        
        rsp = std::string(reinterpret_cast<const char*>(&temp_rsp), sizeof(temp_rsp.public_rsp_header) + 4);
        return true;
    });

    mc::milliseconds interval(100);
    uint8_t          package_id = 0;
    m_cooling->start_ncsi_update_task_mellanox(m_ncsi, interval, package_id);

    // 等待定时器触发
    std::this_thread::sleep_for(std::chrono::milliseconds(200));

    // 验证温度是否被更新（由于定时器回调会调用 update_chip_temp_by_ncsi）
    // 注意：由于是异步操作，这里主要验证不会崩溃
    m_cooling->stop_ncsi_update_task();
    std::this_thread::sleep_for(std::chrono::milliseconds(10));
    EXPECT_TRUE(true);
}

// ========================= 多实例测试 =========================

TEST_F(NetworkAdapterCoolingTest, MultiInstance) {
    std::vector<mc::shared_ptr<dev::NetworkAdapter_Cooling>> coolings;
    for (int i = 0; i < 3; i++) {
        std::string object_name =
            "cooling_" + std::to_string(i) + "_" + std::to_string(std::time(nullptr)) + "_" +
            std::to_string(i * 1000);
        std::string position = std::to_string(i + 2000);

        auto cooling = mc::make_shared<dev::NetworkAdapter_Cooling>();

        mc::milliseconds interval(1000);
        uint8_t          package_id = i;
        cooling->start_ncsi_update_task_mellanox(m_ncsi, interval, package_id);
        coolings.push_back(cooling);
    }

    std::this_thread::sleep_for(std::chrono::milliseconds(50));

    for (auto& cooling : coolings) {
        if (cooling && m_test_service) {
            try {
                cooling->stop_ncsi_update_task();
                std::this_thread::sleep_for(std::chrono::milliseconds(10));
            } catch (...) {
            }
        }
    }
    coolings.clear();
    std::this_thread::sleep_for(std::chrono::milliseconds(50));
    EXPECT_TRUE(true);
}

// ========================= 综合测试 =========================

TEST_F(NetworkAdapterCoolingTest, CompleteWorkflow) {
    // 1. 设置 MCTP 请求处理器，返回模拟的温度信息
    dev::set_mctp_request_handler([](const mc::dict& ctx, const std::vector<uint8_t>& data,
                                     std::string& rsp) {
        if (!ctx.contains("PacketType") ||
            ctx.at("PacketType").as<int64_t>() != OEM_COMMAND) {
            return false;
        }
        if (data.size() < 8 || data[5] != OEM_MLNX_GET_TEMP_CMD || data[6] != OEM_MLNX_GET_TEMP_PARA) {
            return false;
        }
        
        oem_mlnx_temp_rsp_t temp_rsp = {};
        temp_rsp.public_rsp_header.response_code = host_to_be16(COMMAND_COMPLETED);
        temp_rsp.public_rsp_header.reason_code = host_to_be16(NOERROR_OR_NOREASON);
        temp_rsp.public_rsp_header.manufacturer_id = MELLANOX_MANUFACTURE_ID_REP;
        temp_rsp.public_rsp_header.command_id = OEM_MLNX_GET_TEMP_CMD;
        temp_rsp.public_rsp_header.parameter = OEM_MLNX_GET_TEMP_PARA;
        temp_rsp.max_operating_temp = 100;
        temp_rsp.cur_temp = 70;
        
        rsp = std::string(reinterpret_cast<const char*>(&temp_rsp), sizeof(temp_rsp.public_rsp_header) + 4);
        return true;
    });

    // 2. 启动任务
    mc::milliseconds interval(1000);
    uint8_t          package_id = 0;
    m_cooling->start_ncsi_update_task_mellanox(m_ncsi, interval, package_id);
    std::this_thread::sleep_for(std::chrono::milliseconds(50));

    // 3. 手动更新芯片温度
    bool result = m_cooling->update_chip_temp_by_ncsi();
    EXPECT_TRUE(result);
    EXPECT_EQ(m_cooling->TemperatureCelsius.get_value(), 70);
    EXPECT_EQ(m_cooling->TemperatureStatus.get_value(), 0);

    // 4. 更新 SFP 温度
    result = m_cooling->update_max_sfp_temperature(85, 0);
    EXPECT_TRUE(result);
    EXPECT_EQ(m_cooling->MaxSFPTemperatureCelsius.get_value(), 85);
    EXPECT_EQ(m_cooling->MaxSFPTemperatureStatus.get_value(), 0);

    // 5. 停止任务
    m_cooling->stop_ncsi_update_task();
    std::this_thread::sleep_for(std::chrono::milliseconds(10));
    EXPECT_TRUE(true);
}

} // namespace test
} // namespace interface
} // namespace mellanox
} // namespace pcie_nic_card
} // namespace drivers

